package com.ddc.study.feature.main.navigation;

import com.ddc.study.entity.Navigation;
import com.ddc.study.net.NetworkUtil;

import java.util.List;

/**
 * Created on 2018/5/22.
 *
 * @author lshun
 * @version 1.0
 */
class NavigationPresenter extends NavigationContract.IPresenter {
    @Override
    void loadNavigationData() {
        Runnable runnable = () -> {
            final List<Navigation> data = NetworkUtil.getNavigationData();

            if (!isViewAttached()) return;
            getView().runOnUIThread(() -> {
                if (isViewAttached()) {
                    getView().showNavigationData(data);
                }
            });
        };

        mThreadPool.submit(runnable);
    }
}
